import { User, Role, Department, Access, Track, Lock, LockRecord } from "@/types/admin"

export const mockRoles: Role[] = [
  {
    id: "role-1",
    name: "管理员",
    description: "拥有系统的所有管理权限。",
    permissions: [
      "manage_users",
      "manage_roles",
      "manage_departments",
      "manage_tracks",
      "manage_templates",
      "void_ticket",
    ],
  },
  {
    id: "role-2",
    name: "操作员",
    description: "负责创建和执行操作票。",
    permissions: ["create_ticket", "execute_ticket", "view_history"],
  },
]

export const mockDepartments: Department[] = [
  { id: "dept-1", name: "通号中心" },
  { id: "dept-2", name: "调度中心" },
  { id: "dept-3", name: "丁堰车辆段" },
  { id: "dept-4", name: "维护保障中心" },
]

// Assign parent departments and managers
mockDepartments[2].parent = mockDepartments[1] // 丁堰车辆段∏ -> 调度中心

export const mockUsers: User[] = [
  {
    id: "user-1",
    employeeId: "CZ001",
    username: "cz001",
    name: "张伟",
    department: mockDepartments[0], // 通号中心
    role: mockRoles[0], // 管理员
    email: "zhangwei@czmetro.com",
    phone: "13800000001",
    status: "active",
    lastLogin: "2024-07-26T10:00:00Z",
    password: "123456",
  },
  {
    id: "user-2",
    employeeId: "CZ002",
    username: "cz002",
    name: "李娜",
    department: mockDepartments[1], // 调度中心
    role: mockRoles[0], // 管理员
    email: "lina@czmetro.com",
    phone: "13800000002",
    status: "active",
    lastLogin: "2024-07-26T11:30:00Z",
    password: "123456",
  },
  {
    id: "user-3",
    employeeId: "CZ003",
    username: "cz003",
    name: "王强",
    department: mockDepartments[2], // 丁堰车辆段
    role: mockRoles[1], // 操作员
    email: "wangqiang@czmetro.com",
    phone: "13800000003",
    status: "active",
    lastLogin: "2024-07-26T09:15:00Z",
    password: "123456",
  },
  {
    id: "user-4",
    employeeId: "CZ004",
    username: "cz004",
    name: "刘静",
    department: mockDepartments[2], // 丁堰车辆段
    role: mockRoles[1], // 操作员
    email: "liujing@czmetro.com",
    phone: "13800000004",
    status: "disabled",
    lastLogin: "2024-07-25T14:00:00Z",
    password: "123456",
  },
  {
    id: "user-5",
    employeeId: "CZ005",
    username: "cz005",
    name: "赵勇",
    department: mockDepartments[3], // 维护保障中心
    role: mockRoles[1], // 操作员
    email: "zhaoyong@czmetro.com",
    phone: "13800000005",
    status: "active",
    lastLogin: "2024-07-26T08:45:00Z",
    password: "123456",
  },
  {
    id: "user-6",
    employeeId: "CZ999",
    username: "superadmin",
    name: "超级管理员",
    department: mockDepartments[0], 
    role: mockRoles[0], // 管理员
    email: "superadmin@czmetro.com",
    phone: "13899999999",
    status: "active",
    lastLogin: "2024-07-27T00:00:00Z",
    password: "123456",
  },
    {
    id: "user-7",
    employeeId: "CZ100",
    username: "operator",
    name: "标准操作员",
    department: mockDepartments[2],
    role: mockRoles[1], // 操作员
    email: "operator@czmetro.com",
    phone: "13810001000",
    status: "active",
    lastLogin: "2024-07-27T01:00:00Z",
    password: "123456",
  },
]

// Assign managers after users are defined
mockDepartments[0].manager = mockUsers[0] // 通号中心 -> 张伟
mockDepartments[1].manager = mockUsers[1] // 调度中心 -> 李娜

export const mockTracks: Track[] = [
  { id: "track-1", name: "11G", code: "11G", type: "停车线", status: "空闲", description: "11号停车线" },
  { id: "track-2", name: "12G", code: "12G", type: "停车线", status: "占用", description: "12号停车线" },
  { id: "track-3", name: "洗车线", code: "XC-01", type: "作业线", status: "作业中", description: "自动洗车线" },
  { id: "track-4", name: "镟轮线", code: "XL-01", type: "作业线", status: "空闲", description: "镟轮作业线" },
  { id: "track-5", name: "试车线", code: "T-01", type: "试车线", status: "维护中", description: "列车测试专用线" },
]

export const mockLocks: Lock[] = [
  { id: 'lock-001', name: '电子锁A', department: '演示区域', keyId: 'key-101', status: 'locked', lastOperationTime: '2025-07-23 11:31:28' },
  { id: 'lock-002', name: '大门锁', department: '检修库', keyId: 'key-102', status: 'unlocked', lastOperationTime: '2025-07-22 09:15:00' },
  { id: 'lock-003', name: '工具柜锁', department: '物资部', keyId: 'key-103', status: 'faulty', lastOperationTime: '2025-07-21 14:00:30' },
  { id: 'lock-004', name: '11轨道锁', department: '运用车间', keyId: 'key-104', status: 'maintenance', lastOperationTime: '2025-07-20 18:45:10' },
  { id: 'lock-005', name: '12轨道锁', department: '运用车间', keyId: 'key-105', status: 'locked', lastOperationTime: '2025-07-23 10:05:00' },
  { id: 'lock-006', name: '配电室门锁', department: '动力车间', keyId: 'key-106', status: 'locked', lastOperationTime: '2025-07-23 08:30:00' },
  { id: 'lock-007', name: '危化品柜锁', department: '物资部', keyId: 'key-107', status: 'locked', lastOperationTime: '2025-07-22 16:20:15' },
  { id: 'lock-008', name: '北门门禁', department: '安保部', keyId: 'key-108', status: 'unlocked', lastOperationTime: '2025-07-23 11:00:00' },
  { id: 'lock-009', name: '13轨道锁', department: '运用车间', keyId: 'key-109', status: 'locked', lastOperationTime: '2025-07-21 07:45:33' },
  { id: 'lock-010', name: '档案室门锁', department: '综合管理部', keyId: 'key-110', status: 'locked', lastOperationTime: '2025-07-19 12:00:00' },
  { id: 'lock-011', name: '电子锁B', department: '演示区域', keyId: 'key-111', status: 'unlocked', lastOperationTime: '2025-07-23 11:25:18' },
  { id: 'lock-012', name: '服务器机柜锁', department: '信息技术部', keyId: 'key-112', status: 'locked', lastOperationTime: '2025-07-22 20:10:05' },
  { id: 'lock-013', name: '14轨道锁', department: '运用车间', keyId: 'key-113', status: 'maintenance', lastOperationTime: '2025-07-23 09:00:00' },
  { id: 'lock-014', name: '南门门禁', department: '安保部', keyId: 'key-114', status: 'locked', lastOperationTime: '2025-07-23 06:00:00' },
  { id: 'lock-015', name: '2号工具柜锁', department: '物资部', keyId: 'key-115', status: 'locked', lastOperationTime: '2025-07-22 11:30:45' },
  { id: 'lock-016', name: '控制中心门锁', department: '调度中心', keyId: 'key-116', status: 'unlocked', lastOperationTime: '2025-07-23 08:05:12' },
  { id: 'lock-017', name: '15轨道锁', department: '运用车间', keyId: 'key-117', status: 'faulty', lastOperationTime: '2025-07-22 15:00:00' },
  { id: 'lock-018', name: '3号配电室门锁', department: '动力车间', keyId: 'key-118', status: 'locked', lastOperationTime: '2025-07-21 17:55:21' },
];

export const mockLockRecords: LockRecord[] = [
  { id: 'rec-001', lockName: '电子锁具', keyName: '蓝牙钥匙', keyType: 'bluetooth', taskName: '测试开锁任务', department: '演示区域', user: '顾杰', type: 'open', time: '2025-07-23 11:31:28', result: 'success' },
  { id: 'rec-002', lockName: '电子锁具', keyName: '蓝牙钥匙', keyType: 'bluetooth', taskName: '测试开锁任务', department: '演示区域', user: '顾杰', type: 'close', time: '2025-07-23 11:31:24', result: 'failure', reason: '信号干扰' },
  { id: 'rec-003', lockName: '大门锁', keyName: 'NFC卡', keyType: 'nfc', taskName: '日常巡检', department: '检修库', user: '张伟', type: 'open', time: '2025-07-22 09:15:00', result: 'success' },
  { id: 'rec-004', lockName: '12轨道锁', keyName: '蓝牙钥匙-05', keyType: 'bluetooth', taskName: '列车入库检查', department: '运用车间', user: '李娜', type: 'open', time: '2025-07-23 10:05:00', result: 'success' },
  { id: 'rec-005', lockName: '配电室门锁', keyName: 'NFC-D01', keyType: 'nfc', taskName: '月度设备巡检', department: '动力车间', user: '王强', type: 'open', time: '2025-07-23 08:30:00', result: 'success' },
  { id: 'rec-006', lockName: '危化品柜锁', keyName: '蓝牙钥匙-07', keyType: 'bluetooth', taskName: '领取清洁用品', department: '物资部', user: '赵敏', type: 'close', time: '2025-07-22 16:20:15', result: 'success' },
  { id: 'rec-007', lockName: '北门门禁', keyName: 'NFC-A02', keyType: 'nfc', taskName: '进入厂区', department: '安保部', user: '周华', type: 'open', time: '2025-07-23 11:00:00', result: 'success' },
  { id: 'rec-008', lockName: '13轨道锁', keyName: '蓝牙钥匙-09', keyType: 'bluetooth', taskName: '列车出库准备', department: '运用车间', user: '吴刚', type: 'close', time: '2025-07-21 07:45:33', result: 'failure', reason: '钥匙电量低' },
  { id: 'rec-009', lockName: '档案室门锁', keyName: 'NFC-C01', keyType: 'nfc', taskName: '查阅资料', department: '综合管理部', user: '孙悦', type: 'open', time: '2025-07-19 12:00:00', result: 'success' },
  { id: 'rec-010', lockName: '电子锁B', keyName: '蓝牙钥匙-11', keyType: 'bluetooth', taskName: '演示区域巡检', department: '演示区域', user: '顾杰', type: 'open', time: '2025-07-23 11:25:18', result: 'success' },
  { id: 'rec-011', lockName: '服务器机柜锁', keyName: 'NFC-IT01', keyType: 'nfc', taskName: '服务器维护', department: '信息技术部', user: '郑成功', type: 'close', time: '2025-07-22 20:10:05', result: 'success' },
  { id: 'rec-012', lockName: '14轨道锁', keyName: '蓝牙钥匙-13', keyType: 'bluetooth', taskName: '轨道维护', department: '运用车间', user: '陈浩', type: 'open', time: '2025-07-23 09:00:00', result: 'success' },
  { id: 'rec-013', lockName: '南门门禁', keyName: 'NFC-A01', keyType: 'nfc', taskName: '夜间巡逻', department: '安保部', user: '刘雄', type: 'open', time: '2025-07-23 06:00:00', result: 'success' },
  { id: 'rec-014', lockName: '2号工具柜锁', keyName: '蓝牙钥匙-15', keyType: 'bluetooth', taskName: '领取维修工具', department: '物资部', user: '冯远', type: 'close', time: '2025-07-22 11:30:45', result: 'success' },
  { id: 'rec-015', lockName: '控制中心门锁', keyName: 'NFC-CC01', keyType: 'nfc', taskName: '调度员交接班', department: '调度中心', user: '朱珠', type: 'open', time: '2025-07-23 08:05:12', result: 'success' },
  { id: 'rec-016', lockName: '15轨道锁', keyName: '蓝牙钥匙-17', keyType: 'bluetooth', taskName: '故障排查', department: '运用车间', user: '钱坤', type: 'open', time: '2025-07-22 15:00:00', result: 'failure', reason: '锁芯卡滞' },
  { id: 'rec-017', lockName: '3号配电室门锁', keyName: 'NFC-D03', keyType: 'nfc', taskName: '季度设备检修', department: '动力车间', user: '王强', type: 'close', time: '2025-07-21 17:55:21', result: 'success' },
  { id: 'rec-018', lockName: '大门锁', keyName: 'NFC-A02', keyType: 'nfc', taskName: '访客接待', department: '安保部', user: '周华', type: 'open', time: '2025-07-23 14:00:00', result: 'success' },
];

export const mockAccesses: Access[] = [
  {
    id: "access-001",
    name: "主控室门禁",
    location: "丁堰车辆段主控室",
    type: "刷卡门禁",
    status: "正常",
    lastMaintenance: "2024/07/15 10:30",
    track: mockTracks[0], // 关联联合检修库1号线
  },
  {
    id: "access-002",
    name: "维修区域门禁",
    location: "丁堰车辆段维修区",
    type: "人脸识别",
    status: "正常",
    lastMaintenance: "2024/07/10 14:45",
    track: mockTracks[1], // 关联联合检修库2号线
  },
  {
    id: "access-003",
    name: "车库入口门禁",
    location: "丁堰车辆段车库入口",
    type: "双重验证",
    status: "维护中",
    lastMaintenance: "2024/07/20 09:15",
    track: mockTracks[2], // 关联停车线10号线
  },
  {
    id: "access-004",
    name: "配电室门禁",
    location: "丁堰车辆段配电室",
    type: "指纹识别",
    status: "故障",
    lastMaintenance: "2024/06/30 16:20",
    // 无关联股道
  },
  {
    id: "access-005",
    name: "监控中心门禁",
    location: "丁堰车辆段监控中心",
    type: "刷卡门禁",
    status: "正常",
    lastMaintenance: "2024/07/18 11:00",
    track: mockTracks[4], // 关联试车线
  },
] 